﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;


namespace TowerDefender.Graphics
{
    public class MapManager
    {
        public static Canvas CreateMap(Window window, Model.Map map)
        {
            Canvas canvas = new Canvas();
            window.Content = canvas;
            canvas.Width = window.Width * 0.9;
            canvas.Height = window.Height * 0.8;
            canvas.Background = Brushes.Green;

            PathGeometry pathGeometry = new PathGeometry();
            PathFigure figure = new PathFigure();
            
            PolyLineSegment poly = new PolyLineSegment();
            

            foreach (var point in map.MapPath.Points)
            {
                poly.Points.Add(new Point(point.X, point.Y));
                
            }
            figure.Segments.Add(poly);
            pathGeometry.Figures.Add(figure);

            Path path = new Path();
            path.Data = pathGeometry;
            path.Stroke = Brushes.Black;
            path.StrokeThickness = 5;

            canvas.Children.Add(path);
            return canvas;
        }
    }
}
